﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI_Test
{
    public partial class SubFormMYSQLConnection : Form
    {
        public SubFormMYSQLConnection()
        {
            InitializeComponent();
            textBoxMYSQLServerName.Text = "localhost";
            textBoxMYSQLDBName.Text = "wcdb";
            textBoxMYSQLUserId.Text = "root";
            textBoxMYSQLPassword.Text = "";
        }

        private void SubFormMYSQLConnection_Load(object sender, EventArgs e)
        {
           
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!validateUserInput())
            {
                return;
            }
        }

        private bool validateUserInput()
        {
            bool isValid = true;
            if (textBoxMYSQLServerName.Text.Trim() == string.Empty || textBoxMYSQLDBName.Text.Trim() == string.Empty
                || textBoxMYSQLUserId.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Please fill all required fields.", "Error: Invalid entry");
                isValid = false;
            }
            //if (textBoxMYSQLDBName.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("Database name is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            //if (textBoxMYSQLUserId.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("User ID is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            //if (textBoxMYSQLPassword.Text.Trim() == string.Empty)
            //{
            //    MessageBox.Show("Password is required.", "Error: Invalid entry");
            //    isValid = false;
            //}
            return isValid;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void textBoxMYSQLServerName_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
